/********************************************************************
  Copyright: 2011 Alexander Sokoloff <sokoloff.a@gmail.ru>

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License.
  version 2 as published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*********************************************************************/

#ifndef TRAYICON_H
#define TRAYICON_H

#include <QtGui/QSystemTrayIcon>
#include <QtGui/QAction>
#include <QtCore/QString>
#include <QtCore/QProcess>
#include <QIcon>
#include <QSettings>

class QIcon;

class TrayIcon : public QSystemTrayIcon
{
    Q_OBJECT

public:
    explicit TrayIcon(QObject *parent = 0);
    virtual ~TrayIcon();

protected:
    virtual bool event(QEvent* e);

private:
    QString trackInfo() const { return mTrackInfo; }
    void setTrackInfo(const QString& trackInfo);
    void updateToolTip();
    //void createMenu();
    //QAction* mPlayAction;
    //QAction* mStopAction;
    QProcess mPlayer;
    QString mTitle;
    QString mUrl;
    QString mTrackInfo;
    int mBitrate;
    QIcon mIconOn;
    QIcon mIconOff;
    QSettings mSettings;
    bool mMenuByRightClick;
    bool isPlaying();



private slots:
    void playStop();
    void play();
    void stop();
    void dataReady();
    void changeStation();
    void playerStateChanged(QProcess::ProcessState newState);
    void showMenu();
    void clicked(QSystemTrayIcon::ActivationReason reason);

};

#endif // TRAYICON_H
